package www.Demo.array;
import java.util.Scanner;
/**
 @author pu
 1. 重写猜拳要求加入以下几个功能
    1. 游戏采取5局3胜
    2. 加入积分,在游戏退出时显式当前用户的积分
        1. 赢的次数
        2. 输的次数
        3. 平局次数
 */
public class homework1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String computerName = "";
        String playerName = "";
        int num=0;
        System.out.println("******************************");
        System.out.println("**********猜拳  开始**********");
        System.out.println("******************************");
        System.out.println("出拳规则：1.剪刀  2.石头  3.布");
        System.out.print("请选择对方角色（1.刘备  2.孙权  3.曹操）：");
        num = scan.nextInt();
        switch(num) {
            case 1:
                computerName = "刘备";
                break;
            case 2:
                computerName = "孙权";
                break;
            case 3:
                computerName = "曹操";
                break;
            default:
                computerName = "无名2";
                break;
        }
        System.out.print("请输入你的名字：");
        playerName = scan.next();
        System.out.println(playerName+"\tVS\t"+computerName);
        String answer = "";
        String isTrue = "y";
        String result = "";
        System.out.print("要开始吗？（y/n）:");
        answer = scan.next();
        while(isTrue.equalsIgnoreCase(answer)) {
            System.out.println("*******************************************");
            System.out.print("请出拳：1.剪刀  2.石头  3.布（输入相应数字）：");
            System.out.println("\n");
            num = scan.nextInt();
            switch(num) {
                case 1:
                    result = "剪刀";
                    break;
                case 2:
                    result = "石头";
                    break;
                case 3:
                    result = "布";
                    break;
                default:
                    result = "未知";
                    break;
            }
            System.out.print("你出拳：\t"+result);
            System.out.println("\n");
            int num1 = 0;
            String result1 = "";
            num1 = (int)(Math.random()*3+1);
            switch(num1) {
                case 1:
                    result1 = "剪刀";
                    break;
                case 2:
                    result1 = "石头";
                    break;
                case 3:
                    result1 = "布";
                    break;
                default:
                    result1 = "未知";
                    break;
            }
            System.out.print(computerName+"出拳：\t"+result1);
            System.out.println("\n");
            System.out.println("*******************************************");
            System.out.print("是否开始下一局（y/n）:");
            answer = scan.next();

        }
        System.out.println("*******************************************");
        System.out.println("欢迎下次再来！");





    }
}
